#import <Foundation/Foundation.h>
#import "JokeManager.h"
#import "JokePageCell.h"
#import "JokeModel.h"
#import "EGORefreshTableHeaderView.h"
#import "BaseUIViewController.h"
#import "EasyTableView.h"
#import "JokeActionBar.h"
#import "MBProgressHUD.h"

@protocol JokePageViewDelegate;

@class JPVUserStateBase;
@class JPVUserStateLogin;
@class JPVUserStateLogout;

@interface JokePageView : UIView <UITableViewDelegate,UIScrollViewDelegate,UIGestureRecognizerDelegate,EasyTableViewDelegate,JokeActionBarDelegate,BaseUIViewControllerDelegate> {

    IBOutlet UIView             *mainTableContainer;
    EasyTableView               *mainTable;
    
    IBOutlet UIView             *jokeActionBarContainer;
    JokeActionBar               *jokeActionBar;
    
    IBOutlet UIView             *commentTips;
    
    BOOL                        autoSelecting;
    
//    IBOutlet UIView             *jumper;
//    IBOutlet UIImageView        *leftArrow;
//    IBOutlet UIImageView        *rightArrow;
//    IBOutlet UIImageView        *finger;
    IBOutlet UIImageView        *indicator;
    BOOL                        jumping;
    CGPoint                     jumpingPoint;
    BOOL                        dragging;
    CGPoint                     draggingPoint;
    
    JokePageCell                *frontCell;
    JokePageCell                *backCell;
}

@property (assign, nonatomic) BaseUIViewController<JokePageViewDelegate, JokePageCellDelegate> *owner;
@property (retain, atomic) JokePageCell                 *cellPlaying;
@property (retain, atomic) JokeManager                  *jokeManagerPlaying;
@property (copy, atomic) NSIndexPath                    *jokeIndexPathDisplaying;
@property (retain, nonatomic) JPVUserStateLogin             *userStateLogin;
@property (retain, nonatomic) JPVUserStateLogout            *userStateLogout;
@property (assign, nonatomic) JPVUserStateBase              *currentUserState;

- (void)start:(BaseUIViewController<JokePageViewDelegate, JokePageCellDelegate> *)pOwner :(JokeManager *)pJokeManagerPlaying;
- (void)reload:(JokeManager *)pJokeManager :(NSIndexPath *)pJokeIndexPath;
- (void)doneNew:(JokeManager *)pJokeManager :(int)newCount;
- (void)doneNext:(JokeManager *)pJokeManager :(int)nextCount;
- (void)doneNewAndNext:(JokeManager *)pJokeManager :(int)newCount :(int)nextCount;
//- (void)gettingNew:(JokeManager *)pJokeManager;
//- (void)gettingNext:(JokeManager *)pJokeManager;
- (void)zoomIn;
- (void)zoomOut;
- (void)hideBar;
- (void)showBar;
- (void)startComment;
- (void)startFavorite;
- (void)setUserState:(JPVUserStateBase *)newState;

@end

@protocol JokePageViewDelegate<NSObject>
@optional
- (void)JPVselect:(JokeManager *)pJokeManager :(NSIndexPath *)pJokeIndexPath;
- (void)JPVshowList;
- (void)JPVshare;
- (void)JPVlogin;                       //需要登录
@end

#pragma mark ---------用户是否登录的状态机-----
@protocol JPVUserStateDelegate<NSObject>
@optional
-(void)JPVUScomment;
-(void)JPVUSfavorite;
-(void)JPVUScell;
@end

@interface JPVUserStateBase : NSObject<JPVUserStateDelegate>
{
    JokePageView       *owner;
}
-(id)init:(JokePageView *)powner;
@end

@interface JPVUserStateLogin : JPVUserStateBase
@end

@interface JPVUserStateLogout : JPVUserStateBase
@end
